﻿<%@ WebService Language="C#" Class="ContractAddUpdateWebService" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Text;

[WebService(Namespace = "http://localhsot/ContractAddUpdate")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class ContractAddUpdateWebService  : System.Web.Services.WebService {

    ContractDAO comm = new ContractDAO();
    ContractModel model = new ContractModel();
    
    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }

    [WebMethod]//
    public int ContractColumnAddUpdate(string coCode, string userCode, string columnPosition, string columnValue, string contractNoMain, string columnID)
    {
        //CommonMethod.IsTimeOutUserCodeAndCoCode(page, CommonModel.errorTimeOutUrl1);
        model.CoCode = coCode;
        model.UserCode = userCode;
        model.ColumnID = columnID;
        model.ColumnPosition = columnPosition;
        model.ColumnValue = columnValue;
        model.ContractNoMain = contractNoMain;

        return comm.ContractColumnAddUpdate(model);
    }

    [WebMethod]
    public int ContractDelete(string contractNos)
    {
        return comm.ContractDelete(contractNos);
    }

    [WebMethod]
    public string ShowAddRepeat(string columnPosition, string contractNoMain, string coCode, string userCode, string contractGroup)
    {
        model.CoCode = coCode;
        model.UserCode = userCode;
        model.ContractNoMain = contractNoMain;
        model.ColumnPosition = columnPosition;
        model.contractGroup = contractGroup;
        
        return comm.GetColumnsToShow(model);       
    }

    [WebMethod]
    public string ShowLog(string columnType, string contracNo, string coCode)
    {
        model.ColumnType = columnType;
        model.ContractNoMain = contracNo;
        model.CoCode = coCode;

        return comm.ShowLog(model);
    }

    [WebMethod]
    public string ContractFielsShow(string path, int deleteFlag)
    {
        return comm.GetFilesByContract(path, deleteFlag);
    }

    [WebMethod]
    public string ContractFileDelete(string filePath, int deleteFlag)
    {
        string path = Server.MapPath("~/" + filePath);

        System.IO.FileInfo fiL = new System.IO.FileInfo(path);
                
        if (fiL.Exists)
        {
            fiL.Delete();
            return comm.GetFilesByContract(filePath.Substring(0, filePath.LastIndexOf('/')), deleteFlag);
        }
        return "Not File Found!";
    }
}